@layout("/template/container.html",{bg:"bg-white",js:["/js/module/system/limit/add.js"]}){
<form id="formContainer" lay-filter="formContainer" class="layui-form model-form">
    <div class="layui-form-item">
        <label class="layui-form-label">选择服务<span style="color: red;">*</span></label>
        <div class="layui-input-block" id="part0">

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">限流维度<span style="color: red;">*</span></label>
        <div class="layui-input-block">
            <input type="checkbox" name="limit" value="routeId" title="路由ID" lay-filter="limit">
            <input type="checkbox" name="limit" value="appKey" title="appKey" lay-filter="limit">
            <input type="checkbox" name="limit" value="limitIp" title="IP" lay-filter="limit">
        </div>
    </div>

    <div class="layui-form-item layui-hide" id="routeId">
        <label class="layui-form-label">路由ID<span style="color: red;">*</span></label>
        <div class="layui-input-block" id="part1">

        </div>
    </div>
    <div class="layui-form-item layui-hide" id="appKey">
        <label class="layui-form-label">AppId<span style="color: red;">*</span></label>
        <div class="layui-input-block">
            <input name="appKey" type="text" placeholder="需要限流的AppId" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item layui-hide" id="limitIp">
        <label class="layui-form-label">IP<span style="color: red;">*</span></label>
        <div class="layui-input-block">
            <input name="limitIp" type="text" placeholder="多个用英文逗号隔开" class="layui-input"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">限流策略<i class="layui-icon layui-icon-help" style="color: orange;cursor: pointer" onmouseover="showTips(this)" onmouseout="closeTips()"></i></label>
        <div class="layui-input-block">
            <input type="radio" name="limitType" value="1" title="窗口策略" lay-filter="limitType" checked>
            <input type="radio" name="limitType" value="2" title="令牌桶策略" lay-filter="limitType">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">开启状态</label>
        <div class="layui-input-block">
            <input type="checkbox" name="limitStatus" lay-skin="switch" value="1" lay-text="开启|关闭">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">排序<span style="color: red;">*</span></label>
            <div class="layui-input-inline">
                <input name="orderIndex" type="text" class="layui-input" value="0" required lay-verify="required"/>
            </div>
            <div class="layui-form-mid layui-word-aux"> 值小优先执行</div>
        </div>
    </div>

    <div class="layui-form-item limitType" id="limitType1">
        <div class="layui-inline">
            <label class="layui-form-label">请求数<span style="color: red;">*</span></label>
            <div class="layui-form-mid layui-word-aux">每</div>
            <div class="layui-input-inline">
                <input type="text" name="durationSeconds"  autocomplete="off"
                       class="layui-input" value="1">
            </div>
            <div class="layui-form-mid layui-word-aux"> 秒可处理</div>
            <div class="layui-input-inline">
                <input type="text" name="execCountPerSecond" autocomplete="off"
                       class="layui-input" value="5">
            </div>
            <div class="layui-form-mid layui-word-aux"> 个请求</div>
        </div>
    </div>

    <div class="layui-form-item layui-hide limitType" id="limitType2">
        <label class="layui-form-label">令牌桶容量<span style="color: red;">*</span></label>
        <div class="layui-input-block">
            <input name="tokenBucketCount" type="text" class="layui-input" value="5"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        <button class="layui-btn" lay-filter="btnSubmit" lay-submit>保存</button>
    </div>
</form>
<script type="text/html" id="part0-template">
    <select name="serviceId" lay-verify="required" required lay-filter="serviceId">
        {{# layui.each(d.list, function(index, item){ }}
        <option value="{{item.name}}">{{item.name}}</option>
        {{# }); }}
    </select>
</script>

<script type="text/html" id="part1-template">
    <select name="routeId">
        <option value="">可筛选</option>
        {{# layui.each(d.list, function(index, item){ }}
        <option value="{{item.id}}">{{item.name}} {{item.version}}</option>
        {{# }); }}
    </select>
</script>
@}
